package br.com.caelum.controller;

import java.util.List;

import br.com.caelum.dao.AlunoDAO;
import br.com.caelum.model.Aluno;
import br.com.caelum.model.Matricula;
import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;

@Resource
public class AlunosController {
	private final AlunoDAO dao;
	private final Result result;
	
	public AlunosController(AlunoDAO dao, Result result) {
		this.dao = dao;
		this.result = result;
	}
	
	public void adiciona(Aluno aluno) {
		dao.salva(aluno);
		result.redirectTo(this).lista();
	}
	
	public void altera(Aluno aluno) {
		dao.atualiza(aluno);
		result.redirectTo(this).lista();
	}
	
	public Aluno edita(Long id) {
		return dao.carrega(id);
	}
	
	public List<Aluno> lista() {
		return dao.listaTudo();
	}
	
	public void formulario() {
	}
}
